package com.xdf.ecommerce.controller;

import com.xdf.ecommerce.account.BalanceInfo;
import com.xdf.ecommerce.service.IBalanceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author chanchaw
 * @create 2025-11-11 16:48
 */
@Slf4j
@RequiredArgsConstructor
@CrossOrigin
@RestController
@RequestMapping("/balance")
public class BalanceController {
    private final IBalanceService service;

    /**
     * 扣减用户账户的余额
     * @param balanceInfo
     * @return
     */
    @PostMapping("/deductBalance")
    public BalanceInfo deductBalance(@RequestBody BalanceInfo balanceInfo){
        log.info("即将扣减的账户信息：[{}]", balanceInfo.toString());
        return service.deductBalance(balanceInfo);
    }
}
